home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / Multi-Panel Dialogs 1.1 / MPDTest App / Panels / CPowerPanel.cp < prev    next >
Encoding:
Text File  |  1996-02-09  |  3.5 KB  |  116 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:            CPowerPanel.cp
  3.  
  4.     Contains:    Class stub to use as a template for creating your own multi-pane
  5.                     dialog panels.
  6.  
  7.     Written by:    Mike Shields
  8.  
  9.     Copyright:    Copyright © 1996 Mike Shields.  All Rights Reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.                 02/01/96    MSS        New
  14.     To Do:
  15. */
  16. #include "CPowerPanel.h"
  17.  
  18. #include <LStream.h>
  19. #include <LControl.h>
  20.  
  21. struct SPowerPanelRec
  22. {
  23.     Int16        enegyMode;
  24.     Int16        warpDrive;
  25.     Int16        thermRadiators;
  26.     Int16        emergencyPower;
  27. };
  28.  
  29. typedef struct SPowerPanelRec    PowerPanelRec, *PowerPanelDataPtr, **PowerPanelDataHandle;
  30.  
  31. //---------------------------------------------------------------------------
  32. // CPowerPanel::CreateFromStream
  33. //---------------------------------------------------------------------------
  34. CPowerPanel* CPowerPanel::CreateFromStream(LStream* inStream)
  35. {
  36.     return (new CPowerPanel(inStream));
  37. }
  38.  
  39. //---------------------------------------------------------------------------
  40. // CPowerPanel::CPowerPanel
  41. //---------------------------------------------------------------------------
  42. CPowerPanel::CPowerPanel()
  43. {
  44. }
  45.  
  46. //---------------------------------------------------------------------------
  47. // CPowerPanel::CPowerPanel
  48. //---------------------------------------------------------------------------
  49. CPowerPanel::CPowerPanel(const CPowerPanel &inOriginal) 
  50.     : CMPDPanel(inOriginal) 
  51. {
  52. }
  53.  
  54. //---------------------------------------------------------------------------
  55. // CPowerPanel::CPowerPanel
  56. //---------------------------------------------------------------------------
  57. CPowerPanel::CPowerPanel(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo) 
  58.     : CMPDPanel(inPaneInfo, inViewInfo) 
  59. {
  60. }
  61.  
  62. //---------------------------------------------------------------------------
  63. // CPowerPanel::CPowerPanel
  64. //---------------------------------------------------------------------------
  65. CPowerPanel::CPowerPanel(LStream *inStream) 
  66.     : CMPDPanel(inStream)
  67. {
  68. }
  69.  
  70. //---------------------------------------------------------------------------
  71. // CPowerPanel::CPowerPanel
  72. //---------------------------------------------------------------------------
  73. CPowerPanel::~CPowerPanel()
  74. {
  75. }
  76.     
  77. //---------------------------------------------------------------------------
  78. // CPowerPanel::GetData
  79. //---------------------------------------------------------------------------
  80. void CPowerPanel::GetData(Handle inDataToReplace)
  81. {
  82.     LControl        *aControl;
  83.     PowerPanelRec    newPrefs;
  84.     
  85.     aControl = (LControl*)this->FindPaneByID('Save');
  86.     newPrefs.enegyMode = aControl->GetValue();
  87.     aControl = (LControl*)this->FindPaneByID('Warp');
  88.     newPrefs.warpDrive = aControl->GetValue();
  89.     aControl = (LControl*)this->FindPaneByID('Ther');
  90.     newPrefs.thermRadiators = aControl->GetValue();
  91.     aControl = (LControl*)this->FindPaneByID('Emer');
  92.     newPrefs.emergencyPower = aControl->GetValue();    
  93.  
  94.     OSErr anErr = ::PtrToXHand(&newPrefs, inDataToReplace, sizeof(newPrefs));
  95.     ThrowIfOSErr_(anErr);
  96. }
  97.  
  98. //---------------------------------------------------------------------------
  99. // CPowerPanel::SetData
  100. //---------------------------------------------------------------------------
  101. void CPowerPanel::SetData(Handle inData)
  102. {
  103.     LControl        *aControl;
  104.     PowerPanelDataHandle    newPrefs = (PowerPanelDataHandle)inData;
  105.     
  106.     aControl = (LControl*)this->FindPaneByID('Save');
  107.     aControl->SetValue((**newPrefs).enegyMode);
  108.     aControl = (LControl*)this->FindPaneByID('Warp');
  109.     aControl->SetValue((**newPrefs).warpDrive);
  110.     aControl = (LControl*)this->FindPaneByID('Ther');
  111.     aControl->SetValue((**newPrefs).thermRadiators);
  112.     aControl = (LControl*)this->FindPaneByID('Emer');
  113.     aControl->SetValue((**newPrefs).emergencyPower);    
  114. }
  115.  
  116.